<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>日期和时间</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.unixtojd.html">« unixtojd</a></li>
      <li style="float: right;"><a href="intro.datetime.html">简介 »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="refs.calendar.html">日期与时间相关扩展</a></li>
    <li>日期和时间</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="book.datetime" class="book">
 
 <h1 class="title">日期和时间</h1>
 

 
 
 

 









 







 







 






 




 






 





 






 








 









 






 









<ul class="chunklist chunklist_book"><li><a href="intro.datetime.html">简介</a></li><li><a href="datetime.setup.html">安装/配置</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="datetime.requirements.html">需求</a></li><li><a href="datetime.installation.html">安装</a></li><li><a href="datetime.configuration.html">运行时配置</a></li><li><a href="datetime.resources.html">资源类型</a></li></ul></li><li><a href="datetime.constants.html">预定义常量</a></li><li><a href="datetime.examples.html">范例</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="datetime.examples-arithmetic.html">日期/时间算法</a></li></ul></li><li><a href="class.datetime.html">DateTime</a> — DateTime 类<ul class="chunklist chunklist_book chunklist_children"><li><a href="datetime.add.html">DateTime::add</a> — 修改 DateTime 对象，增加天、月、年、小时、分钟以及秒的数量。</li><li><a href="datetime.construct.html">DateTime::__construct</a> — 返回新的 DateTime 对象</li><li><a href="datetime.createfromformat.html">DateTime::createFromFormat</a> — 根据指定格式解析时间字符串</li><li><a href="datetime.createfromimmutable.html">DateTime::createFromImmutable</a> — Returns new DateTime instance encapsulating the given DateTimeImmutable object</li><li><a href="datetime.createfrominterface.html">DateTime::createFromInterface</a> — Returns new DateTime object encapsulating the given DateTimeInterface object</li><li><a href="datetime.getlasterrors.html">DateTime::getLastErrors</a> — 返回警告和错误信息</li><li><a href="datetime.modify.html">DateTime::modify</a> — 修改日期时间对象的值</li><li><a href="datetime.set-state.html">DateTime::__set_state</a> — __set_state 处理程序</li><li><a href="datetime.setdate.html">DateTime::setDate</a> — 设置日期</li><li><a href="datetime.setisodate.html">DateTime::setISODate</a> — 设置 ISO 日期</li><li><a href="datetime.settime.html">DateTime::setTime</a> — 设置时间</li><li><a href="datetime.settimestamp.html">DateTime::setTimestamp</a> — 以 Unix 时间戳的方式设置日期和时间</li><li><a href="datetime.settimezone.html">DateTime::setTimezone</a> — 设置 DateTime 对象的时区</li><li><a href="datetime.sub.html">DateTime::sub</a> — 对 DateTime 对象减去一定量的日、月、年、小时、分钟和秒。</li></ul></li><li><a href="class.datetimeimmutable.html">DateTimeImmutable</a> — The DateTimeImmutable class<ul class="chunklist chunklist_book chunklist_children"><li><a href="datetimeimmutable.add.html">DateTimeImmutable::add</a> — Returns a new object, with added amount of days, months, years, hours, minutes and seconds</li><li><a href="datetimeimmutable.construct.html">DateTimeImmutable::__construct</a> — Returns new DateTimeImmutable object</li><li><a href="datetimeimmutable.createfromformat.html">DateTimeImmutable::createFromFormat</a> — Parses a time string according to a specified format</li><li><a href="datetimeimmutable.createfrominterface.html">DateTimeImmutable::createFromInterface</a> — Returns new DateTimeImmutable object encapsulating the given DateTimeInterface object</li><li><a href="datetimeimmutable.createfrommutable.html">DateTimeImmutable::createFromMutable</a> — Returns new DateTimeImmutable instance encapsulating the given DateTime object</li><li><a href="datetimeimmutable.getlasterrors.html">DateTimeImmutable::getLastErrors</a> — Returns the warnings and errors</li><li><a href="datetimeimmutable.modify.html">DateTimeImmutable::modify</a> — Creates a new object with modified timestamp</li><li><a href="datetimeimmutable.set-state.html">DateTimeImmutable::__set_state</a> — The __set_state handler</li><li><a href="datetimeimmutable.setdate.html">DateTimeImmutable::setDate</a> — Sets the date</li><li><a href="datetimeimmutable.setisodate.html">DateTimeImmutable::setISODate</a> — Sets the ISO date</li><li><a href="datetimeimmutable.settime.html">DateTimeImmutable::setTime</a> — Sets the time</li><li><a href="datetimeimmutable.settimestamp.html">DateTimeImmutable::setTimestamp</a> — Sets the date and time based on a Unix timestamp</li><li><a href="datetimeimmutable.settimezone.html">DateTimeImmutable::setTimezone</a> — Sets the time zone</li><li><a href="datetimeimmutable.sub.html">DateTimeImmutable::sub</a> — Subtracts an amount of days, months, years, hours, minutes and seconds</li></ul></li><li><a href="class.datetimeinterface.html">DateTimeInterface</a> — The DateTimeInterface interface<ul class="chunklist chunklist_book chunklist_children"><li><a href="datetime.diff.html">DateTimeInterface::diff</a> — 返回两个 DateTime 之间的差值</li><li><a href="datetime.format.html">DateTimeInterface::format</a> — 按照指定格式返回格式化后的日期</li><li><a href="datetime.getoffset.html">DateTimeInterface::getOffset</a> — Returns the timezone offset</li><li><a href="datetime.gettimestamp.html">DateTimeInterface::getTimestamp</a> — Gets the Unix timestamp</li><li><a href="datetime.gettimezone.html">DateTimeInterface::getTimezone</a> — Return time zone relative to given DateTime</li><li><a href="datetime.wakeup.html">DateTime::__wakeup</a> — The __wakeup handler</li></ul></li><li><a href="class.datetimezone.html">DateTimeZone</a> — DateTimeZone 类<ul class="chunklist chunklist_book chunklist_children"><li><a href="datetimezone.construct.html">DateTimeZone::__construct</a> — 创建新的DateTimeZone对象</li><li><a href="datetimezone.getlocation.html">DateTimeZone::getLocation</a> — 返回与时区相关的定位信息</li><li><a href="datetimezone.getname.html">DateTimeZone::getName</a> — 返回时区名称</li><li><a href="datetimezone.getoffset.html">DateTimeZone::getOffset</a> — 返回相对于 GMT 的时差</li><li><a href="datetimezone.gettransitions.html">DateTimeZone::getTransitions</a> — Returns all transitions for the timezone</li><li><a href="datetimezone.listabbreviations.html">DateTimeZone::listAbbreviations</a> — 返回一个包含 dst (夏令时)，时差和时区信息的关联数组。</li><li><a href="datetimezone.listidentifiers.html">DateTimeZone::listIdentifiers</a> — 返回包含了所有时区标识符的数字索引数组</li></ul></li><li><a href="class.dateinterval.html">DateInterval</a> — DateInterval 类<ul class="chunklist chunklist_book chunklist_children"><li><a href="dateinterval.construct.html">DateInterval::__construct</a> — Creates a new DateInterval object</li><li><a href="dateinterval.createfromdatestring.html">DateInterval::createFromDateString</a> — Sets up a DateInterval from the relative parts of the string</li><li><a href="dateinterval.format.html">DateInterval::format</a> — Formats the interval</li></ul></li><li><a href="class.dateperiod.html">DatePeriod</a> — DatePeriod 类<ul class="chunklist chunklist_book chunklist_children"><li><a href="dateperiod.construct.html">DatePeriod::__construct</a> — Creates a new DatePeriod object</li><li><a href="dateperiod.getdateinterval.html">DatePeriod::getDateInterval</a> — Gets the interval</li><li><a href="dateperiod.getenddate.html">DatePeriod::getEndDate</a> — Gets the end date</li><li><a href="dateperiod.getrecurrences.html">DatePeriod::getRecurrences</a> — Gets the number of recurrences</li><li><a href="dateperiod.getstartdate.html">DatePeriod::getStartDate</a> — Gets the start date</li></ul></li><li><a href="ref.datetime.html">Date/Time 函数</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="function.checkdate.html">checkdate</a> — 验证一个格里高里日期</li><li><a href="function.date-add.html">date_add</a> — 别名 DateTime::add</li><li><a href="function.date-create-from-format.html">date_create_from_format</a> — 别名 DateTime::createFromFormat</li><li><a href="function.date-create-immutable-from-format.html">date_create_immutable_from_format</a> — 别名 DateTimeImmutable::createFromFormat</li><li><a href="function.date-create-immutable.html">date_create_immutable</a> — 别名 DateTimeImmutable::__construct</li><li><a href="function.date-create.html">date_create</a> — create a new DateTime object</li><li><a href="function.date-date-set.html">date_date_set</a> — 别名 DateTime::setDate</li><li><a href="function.date-default-timezone-get.html">date_default_timezone_get</a> — 取得脚本中所有日期/时间函数所使用的默认时区</li><li><a href="function.date-default-timezone-set.html">date_default_timezone_set</a> — 设置脚本中所有日期/时间函数使用的默认时区</li><li><a href="function.date-diff.html">date_diff</a> — 别名 DateTime::diff</li><li><a href="function.date-format.html">date_format</a> — 别名 DateTime::format</li><li><a href="function.date-get-last-errors.html">date_get_last_errors</a> — 别名 DateTime::getLastErrors</li><li><a href="function.date-interval-create-from-date-string.html">date_interval_create_from_date_string</a> — 别名 DateInterval::createFromDateString</li><li><a href="function.date-interval-format.html">date_interval_format</a> — 别名 DateInterval::format</li><li><a href="function.date-isodate-set.html">date_isodate_set</a> — 别名 DateTime::setISODate</li><li><a href="function.date-modify.html">date_modify</a> — 别名 DateTime::modify</li><li><a href="function.date-offset-get.html">date_offset_get</a> — 别名 DateTime::getOffset</li><li><a href="function.date-parse-from-format.html">date_parse_from_format</a> — Get info about given date formatted according to the specified format</li><li><a href="function.date-parse.html">date_parse</a> — 返回指定日期/时间的详细信息的关联数组</li><li><a href="function.date-sub.html">date_sub</a> — 别名 DateTime::sub</li><li><a href="function.date-sun-info.html">date_sun_info</a> — Returns an array with information about sunset/sunrise and twilight begin/end</li><li><a href="function.date-sunrise.html">date_sunrise</a> — 返回给定的日期与地点的日出时间</li><li><a href="function.date-sunset.html">date_sunset</a> — 返回给定的日期与地点的日落时间</li><li><a href="function.date-time-set.html">date_time_set</a> — 别名 DateTime::setTime</li><li><a href="function.date-timestamp-get.html">date_timestamp_get</a> — 别名 DateTime::getTimestamp</li><li><a href="function.date-timestamp-set.html">date_timestamp_set</a> — 别名 DateTime::setTimestamp</li><li><a href="function.date-timezone-get.html">date_timezone_get</a> — 别名 DateTime::getTimezone</li><li><a href="function.date-timezone-set.html">date_timezone_set</a> — 别名 DateTime::setTimezone</li><li><a href="function.date.html">date</a> — 格式化 Unix 时间戳</li><li><a href="function.getdate.html">getdate</a> — 获取日期/时间信息</li><li><a href="function.gettimeofday.html">gettimeofday</a> — 取得当前时间</li><li><a href="function.gmdate.html">gmdate</a> — 格式化 GMT/UTC 日期／时间</li><li><a href="function.gmmktime.html">gmmktime</a> — 取得 GMT 日期的 UNIX 时间戳</li><li><a href="function.gmstrftime.html">gmstrftime</a> — 根据区域设置格式化 GMT/UTC 时间/日期</li><li><a href="function.idate.html">idate</a> — 将本地日期/时间格式化为整数</li><li><a href="function.localtime.html">localtime</a> — 取得本地时间</li><li><a href="function.microtime.html">microtime</a> — 返回当前 Unix 时间戳和微秒数</li><li><a href="function.mktime.html">mktime</a> — 取得一个日期的 Unix 时间戳</li><li><a href="function.strftime.html">strftime</a> — 根据区域设置格式化本地时间/日期</li><li><a href="function.strptime.html">strptime</a> — 解析由 strftime 生成的日期／时间</li><li><a href="function.strtotime.html">strtotime</a> — 将任何英文文本日期时间描述解析为 Unix 时间戳</li><li><a href="function.time.html">time</a> — 返回当前的 Unix 时间戳</li><li><a href="function.timezone-abbreviations-list.html">timezone_abbreviations_list</a> — 别名 DateTimeZone::listAbbreviations</li><li><a href="function.timezone-identifiers-list.html">timezone_identifiers_list</a> — 别名 DateTimeZone::listIdentifiers</li><li><a href="function.timezone-location-get.html">timezone_location_get</a> — 别名 DateTimeZone::getLocation</li><li><a href="function.timezone-name-from-abbr.html">timezone_name_from_abbr</a> — Returns a timezone name by guessing from abbreviation and UTC offset</li><li><a href="function.timezone-name-get.html">timezone_name_get</a> — 别名 DateTimeZone::getName</li><li><a href="function.timezone-offset-get.html">timezone_offset_get</a> — 别名 DateTimeZone::getOffset</li><li><a href="function.timezone-open.html">timezone_open</a> — 别名 DateTimeZone::__construct</li><li><a href="function.timezone-transitions-get.html">timezone_transitions_get</a> — 别名 DateTimeZone::getTransitions</li><li><a href="function.timezone-version-get.html">timezone_version_get</a> — 获取 timezonedb 版本</li></ul></li><li><a href="datetime.formats.html">Supported Date and Time Formats</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="datetime.formats.time.html">Time Formats</a></li><li><a href="datetime.formats.date.html">Date Formats</a></li><li><a href="datetime.formats.compound.html">Compound Formats</a></li><li><a href="datetime.formats.relative.html">Relative Formats</a></li></ul></li><li><a href="timezones.html">所支持的时区列表</a><ul class="chunklist chunklist_book chunklist_children"><li><a href="timezones.africa.html">非洲</a></li><li><a href="timezones.america.html">美洲</a></li><li><a href="timezones.antarctica.html">南极洲</a></li><li><a href="timezones.arctic.html">北极</a></li><li><a href="timezones.asia.html">亚洲</a></li><li><a href="timezones.atlantic.html">大西洋</a></li><li><a href="timezones.australia.html">澳洲</a></li><li><a href="timezones.europe.html">欧洲</a></li><li><a href="timezones.indian.html">印度</a></li><li><a href="timezones.pacific.html">太平洋地区</a></li><li><a href="timezones.others.html">其他</a></li></ul></li></ul></div></div></div></body></html>